package com.hb.trade.api.routine.controller.center.au;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.hb.core.pojo.center.au.dto.OrgCollectionDTO;
import com.hb.core.pojo.center.au.dto.OrgDTO;
import com.hb.core.pojo.center.au.dto.OrgPayeeDTO;
import com.hb.core.pojo.center.au.dto.ZappUserDTO;
import com.hb.core.pojo.center.au.entity.OrgCollection;
import com.hb.core.pojo.center.au.entity.User;
import com.hb.core.pojo.enums.RoleSignEnum;
import com.hb.core.pojo.parent.PageResult;
import com.hb.trade.api.routine.service.ExpertUserService;
import com.hb.trade.client.center.OrgClient;
import com.hb.trade.client.center.UserClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.fzzn.core.auth.shiro.util.ShiroUtil;
import org.fzzn.core.component.treebuilder.util.TreeUtil;
import org.fzzn.core.model.enums.MsgEnum;
import org.fzzn.core.model.msg.Message;
import org.fzzn.core.model.msg.ResponseDto;
import org.fzzn.core.util.Enums;
import org.fzzn.core.util.ResultUtil;
import org.fzzn.core.web.anno.Version;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 企业信息管理
 *
 * @author zhaojk
 */
@Slf4j
@Version(1.0)
@Api(tags = {"企业信息管理"})
@RequestMapping("/{version}")
@RestController
public class ApiOrgController {

    protected final OrgClient orgClient;
    protected final ExpertUserService expertUserService;
    protected final UserClient userClient;

    public ApiOrgController(OrgClient orgClient,
                            ExpertUserService expertUserService, UserClient userClient) {
        this.orgClient = orgClient;
        this.expertUserService = expertUserService;
        this.userClient = userClient;
    }

    /**
     * 企业列表信息，带分页
     *
     * @return
     */
    @ApiOperation(value = "企业列表信息(返回分页对象)", notes = "企业列表信息(返回分页对象)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页数", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "pageSize", value = "每夜条数", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orgName", value = "企业名称", dataTypeClass = String.class),
            @ApiImplicitParam(name = "creditCode", value = "信用代码", dataTypeClass = String.class),
            @ApiImplicitParam(name = "showLoginUser", value = "是否展示当前登录的企业（1，不展示）", dataTypeClass = Integer.class)
    })
    @PostMapping("/org/pageOrgs")
    public ResponseDto pageOrgs(@RequestBody OrgDTO orgDTO) {

        Message<User> user = userClient.getByUserId(ShiroUtil.getUserId());
        // 当前登录的企业id
        if (user.isSuccess() && user.getData() != null) {
            orgDTO.setOrgId(user.getData().getOrgId());
        }
        Message<PageResult<OrgDTO>> pagOrgMsg = orgClient.pageOrgs(orgDTO);
        if (pagOrgMsg.isSuccess()) {
            return ResultUtil.msg(pagOrgMsg);
        }
        return ResultUtil.FAIL;
    }

    /**
     * @param orgDTO:
     * @Description: 完善企业信息
     * @Author: zhongdl
     * @Date:2022/1/15 14:48
     * @return: {@link ResponseDto }
     **/
    @ApiOperation(value = "完善企业信息", notes = "完善企业信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orgExt.capital", value = "注册资本", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgExt.regTime", value = "注册日期", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "orgExt.addressInfo", value = "注册地址", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgExt.orgEmail", value = "企业邮箱", dataTypeClass = String.class),
            @ApiImplicitParam(name = "legalName", value = "法人姓名", dataTypeClass = String.class),
            @ApiImplicitParam(name = "certificateType", value = "证件类型", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "certificateNumber", value = "证件号码", dataTypeClass = String.class),
    })
    @PostMapping("/org/perfectInformation")
    public ResponseDto perfectInformation(@RequestBody OrgDTO orgDTO) {
        String paramsValid = orgDTO.paramsValid();
        if (StrUtil.isNotEmpty(paramsValid)) {
            return ResultUtil.fail(paramsValid);
        }
        if (orgDTO.getOrgExt() == null) {
            return ResultUtil.fail(MsgEnum.INCORRECT_PARAM);
        }
        //判断用户是否超级管理员和企业管理员
        Message<User> userMessage = userClient.getByUserId(ShiroUtil.getUserId());
        if (!userMessage.isSuccess() || userMessage.getData() == null) {
            return ResultUtil.fail("用户信息不存在,请重新登录");
        }

        orgDTO.setId(ShiroUtil.getOrgId());
        Message<Boolean> perfectInformation = orgClient.perfectInformation(orgDTO);
        if (perfectInformation.isSuccess()) {
            return ResultUtil.msg(true);
        }
        return ResultUtil.FAIL;
    }

    /**
     * 根据id查询企业信息
     *
     * @return
     */
    @ApiOperation(value = "根据id查询企业信息", notes = "根据id查询企业信息")
    @PostMapping("/org/getOrgById")
    public ResponseDto<?> getOrgById() {
        Long orgId = ShiroUtil.getOrgId();
        if (orgId == null) {
            return ResultUtil.fail("不存在企业 请联系管理员");
        }
        Message<OrgDTO> org = orgClient.getOrgById(orgId);
        if (org.isSuccess()) {
            //返回总公司信息
            if (org.getData() != null && !org.getData().getParentId().equals(0L)) {
                Message<OrgDTO> headOffice = orgClient.getHeadOffice(orgId);
                return ResultUtil.msg(headOffice);
            }
            return ResultUtil.msg(org);
        }
        return ResultUtil.FAIL;
    }

    @ApiOperation(value = "查询组织架构的父级公司和所有子名称", notes = "查询组织架构的父级公司和所有子名称")
    @PostMapping("/org/getTreeOrg")
    @Version(1.1)
    public ResponseDto<?> getTreeOrg1_1() {
        Integer roleSign = ShiroUtil.getExtInfoInt("roleSign");
        Long orgId = ShiroUtil.getOrgId();
        Message<List<OrgDTO>> listMessage;
        if (Enums.equals(RoleSignEnum.BIDDER, roleSign)) {
            // 投标人没有分公司的概念, 只查询当前所在企业
            Message<OrgDTO> orgDTOMessage = orgClient.getOrgById(orgId);
            listMessage = new Message<>();
            listMessage.setMessage(orgDTOMessage.getMessage());
            listMessage.setCode(orgDTOMessage.getCode());
            listMessage.setData(CollUtil.list(false, orgDTOMessage.getData()));
        } else {
            listMessage = orgClient.listParentAndSon(orgId);
        }
        if (listMessage.isSuccess()) {
            JSONArray tree = TreeUtil.getTree(listMessage.getData(), MapUtil.of("title", "orgName"), true);
            return ResultUtil.msg(true, tree);
        }
        return ResultUtil.msg(listMessage);
    }

    /**
     * @Description: 查询组织架构的父级公司名称
     * @Author: zhongdl
     * @Date:2022/1/20 10:53
     * @return: {@link ResponseDto }
     **/
    @ApiOperation(value = "查询组织架构的父级公司和所有子名称", notes = "查询组织架构的父级公司和所有子名称")
    @PostMapping("/org/getTreeOrg")
    public ResponseDto getTreeOrg() {
        //判断用户是否超级管理员和企业管理员
        Message<User> userMessage = userClient.getByUserId(ShiroUtil.getUserId());
        if (userMessage.isFail()) {
            return ResultUtil.msg(userMessage);
        }

        User user = userMessage.getData();
        Message<List<OrgDTO>> orgMsg = orgClient.listByUserInfo(user);
        if (orgMsg.isSuccess()) {
            JSONArray tree = TreeUtil.getTree(orgMsg.getData(), MapUtil.of("title", "orgName"), true);
            return ResultUtil.msg(true, tree);
        }
        return ResultUtil.msg(orgMsg);
    }

    /**
     * @Description: 查询组织架构的父级公司名称
     * @Author: zhongdl
     * @Date:2022/1/20 10:53
     * @return: {@link ResponseDto }
     **/
    @ApiOperation(value = "查询组织架构所有子公司名称", notes = "查询组织架构所有子公司名称")
    @PostMapping("/org/listSonOrg")
    public ResponseDto listSonOrg(@RequestBody OrgDTO orgDTO) {
        Long orgId = orgDTO.getId() == null ? ShiroUtil.getOrgId() : orgDTO.getId();
        Message<List<OrgDTO>> org = orgClient.listSon(orgId);
        if (org.isSuccess()) {
            JSONArray tree = TreeUtil.getTree(org.getData(), MapUtil.of("title", "orgName"), false);
            return ResultUtil.msg(true, tree);
        }
        return ResultUtil.FAIL;
    }

    /**
     * @param orgPayeeDTO:
     * @Description: 新增一个收款方
     * @Author: zhongdl
     * @Date:2022/2/14 9:23
     * @return: {@link ResponseDto }
     **/
    @ApiOperation(value = "新增一个收款方", notes = "新增一个收款方")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "payee", value = "收款方", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgCollectionList.payType", value = "1 支付宝 2 微信 3 银联", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orgCollectionList.collectionOss", value = "收款码oss", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orgCollectionList.collectionName", value = "收款码名称", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orgCollectionList.bankAccount", value = "银行账号", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgCollectionList.bankAccountName", value = "银行户名", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgCollectionList.bankDeposit", value = "开户行", dataTypeClass = String.class),
    })
    @PostMapping("/orgPayee/newOrgPayee")
    public ResponseDto<?> newOrgPayee(@RequestBody OrgPayeeDTO orgPayeeDTO) {
        // 参数验证
        String paramsValid = orgPayeeDTO.paramsValid();
        if (StrUtil.isNotEmpty(paramsValid)) {
            return ResultUtil.fail(paramsValid);
        }

        List<OrgCollectionDTO> orgCollectionDTOS = CollUtil.addAllIfNotContains(orgPayeeDTO.getWeChatInfo(), orgPayeeDTO.getAlipayInfo());
        if (CollUtil.isEmpty(orgCollectionDTOS)) {
            orgCollectionDTOS = CollUtil.list(false);
        }
        if (orgPayeeDTO.getUnionPayInfo() != null) {
            orgCollectionDTOS.add(orgPayeeDTO.getUnionPayInfo());
        }

        orgPayeeDTO.setOrgCollectionList(orgCollectionDTOS);
        ShiroUtil.fillOwner(orgPayeeDTO);
        Message<Long> booleanMessage = orgClient.newOrgPayee(orgPayeeDTO);
        if (booleanMessage.isSuccess()) {
            return ResultUtil.msg(booleanMessage);
        }
        return ResultUtil.FAIL;
    }

    /**
     * @param orgPayeeDTO:
     * @Description: 更新收款方信息
     * @Author: zhongdl
     * @Date:2022/2/14 10:25
     * @return: {@link ResponseDto }
     **/
    @ApiOperation(value = "更新收款方信息", notes = "更新收款方信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "payee", value = "收款方", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgCollectionList.payType", value = "1 支付宝 2 微信 3 银联", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orgCollectionList.collectionOss", value = "收款码oss", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orgCollectionList.collectionName", value = "收款码名称", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "orgCollectionList.bankAccount", value = "银行账号", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgCollectionList.bankAccountName", value = "银行户名", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgCollectionList.bankDeposit", value = "开户行", dataTypeClass = String.class),
    })
    @PostMapping("/orgPayee/updateOrgPayee")
    public ResponseDto updateOrgPayee(@RequestBody OrgPayeeDTO orgPayeeDTO) {
        // 参数验证
        String paramsValid = orgPayeeDTO.paramsValid();
        if (StrUtil.isNotEmpty(paramsValid)) {
            return ResultUtil.fail(paramsValid);
        }

        List<OrgCollectionDTO> orgCollectionDTOS = CollUtil.addAllIfNotContains(orgPayeeDTO.getWeChatInfo(), orgPayeeDTO.getAlipayInfo());
        if (CollUtil.isEmpty(orgCollectionDTOS)) {
            orgCollectionDTOS = CollUtil.list(false);
        }
        if (orgPayeeDTO.getUnionPayInfo() != null) {
            orgCollectionDTOS.add(orgPayeeDTO.getUnionPayInfo());
        }

        orgPayeeDTO.setOrgCollectionList(orgCollectionDTOS);
        ShiroUtil.fillOwner(orgPayeeDTO);

        Message<Boolean> booleanMessage = orgClient.updateOrgPayee(orgPayeeDTO);
        if (booleanMessage.isSuccess()) {
            return ResultUtil.msg(true);
        }
        return ResultUtil.FAIL;
    }

    @ApiOperation(value = "查询收款码信息列表", notes = "查询收款码信息列表")
    @PostMapping("/orgPayee/listOrgPayee")
    public ResponseDto listOrgPayee(@RequestBody OrgPayeeDTO orgPayeeDTO) {
        ShiroUtil.fillOwner(orgPayeeDTO);
        Message<List<OrgPayeeDTO>> listOrgPayee = orgClient.listOrgPayee(orgPayeeDTO);
        if (listOrgPayee.isFail()) {
            return ResultUtil.FAIL;
        }
        return ResultUtil.msg(listOrgPayee);
    }

    @ApiOperation(value = "查询收款码信息列表(分页)", notes = "查询收款码信息列表")
    @PostMapping("/orgPayee/pageOrgPayee")
    public ResponseDto pageOrgPayee(@RequestBody OrgPayeeDTO orgPayeeDTO) {
        ShiroUtil.fillOwner(orgPayeeDTO);
        Message<PageResult> resultMessage = orgClient.pageOrgPayee(orgPayeeDTO);
        if (resultMessage.isFail()) {
            return ResultUtil.FAIL;
        }
        return ResultUtil.msg(resultMessage);
    }

    @ApiOperation(value = "根据id查询收款码详情", notes = "根据id查询收款码详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "收款码id", dataTypeClass = String.class),
    })
    @PostMapping("/orgPayee/getOrgOrgPayeeId")
    public ResponseDto<?> getOrgOrgPayeeId(@RequestBody OrgPayeeDTO orgPayeeDTO) {
        if (orgPayeeDTO.getId() == null) {
            return ResultUtil.fail(MsgEnum.INCORRECT_PARAM);
        }
        ShiroUtil.fillOwner(orgPayeeDTO);
        Message<OrgPayeeDTO> orgCollectionMessage = orgClient.getOrgOrgPayeeId(orgPayeeDTO);
        if (orgCollectionMessage.isSuccess()) {
            return ResultUtil.msg(orgCollectionMessage);
        }
        return ResultUtil.FAIL;
    }

    @ApiOperation(value = "根据id删除收款方", notes = "根据id删除收款方")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "收款码id", dataTypeClass = String.class),
    })
    @PostMapping("/orgPayee/removeOrgPayeeId")
    public ResponseDto removeOrgPayeeId(@RequestBody OrgPayeeDTO orgPayeeDTO) {
        Message<User> userMessage = userClient.getByUserId(ShiroUtil.getUserId());
        if (!userMessage.isSuccess() || userMessage.getData() == null) {
            return ResultUtil.fail("用户信息不存在,请重新登录");
        }

        Message<Boolean> orgCollectionMessage = orgClient.removeOrgPayeeId(orgPayeeDTO);
        if (orgCollectionMessage.isSuccess()) {
            return ResultUtil.msg(orgCollectionMessage);
        }
        if (orgPayeeDTO.getId() == null) {
            return ResultUtil.fail(MsgEnum.INCORRECT_PARAM);
        }
        ShiroUtil.fillOwner(orgPayeeDTO);

        return StrUtil.isNotEmpty(orgCollectionMessage.getMessage()) ? ResultUtil.msg(orgCollectionMessage) : ResultUtil.FAIL;
    }

    @ApiOperation(value = "校验收款方式是否被关联", notes = "校验收款方式是否被关联")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "收款码id", dataTypeClass = String.class),
    })
    @PostMapping("/orgCollection/correlatedFlag")
    public ResponseDto removeOrgPayeeId(@RequestBody OrgCollectionDTO orgCollectionDTO) {
        Message<Boolean> orgCollectionMessage = orgClient.correlatedFlag(orgCollectionDTO);
        return ResultUtil.msg(orgCollectionMessage);
    }

    @ApiOperation(value = "查询收款码详情", notes = "查询收款码详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "收款码id", dataTypeClass = String.class),
            @ApiImplicitParam(name = "ids", value = "收款码id集合", dataTypeClass = String.class)
    })
    @PostMapping("/orgCollection/getOrgCollectionId")
    public ResponseDto<?> getOrgCollectionId(@RequestBody OrgCollectionDTO orgCollectionDTO) {
        List<Long> ids = orgCollectionDTO.getIds();
        if (ids == null) {
            ids = CollUtil.list(false);
        }
        if (orgCollectionDTO.getId() != null) {
            ids.add(orgCollectionDTO.getId());
        }
        CollUtil.removeNull(ids);
        if (CollUtil.isEmpty(ids)) {
            return ResultUtil.msg(MsgEnum.INCORRECT_PARAM);
        }

        List<OrgCollection> collections = CollUtil.list(false);
        OrgCollectionDTO dto = new OrgCollectionDTO();
        Message<OrgCollection> orgCollectionMessage;
        for (Long id : ids) {
            dto.setId(id);
            orgCollectionMessage = orgClient.getOrgCollectionId(dto);
            if (orgCollectionMessage.isSuccess()) {
                collections.add(orgCollectionMessage.getData());
            }
        }
        return ResultUtil.msg(true, collections);
    }

    @ApiOperation(value = "查询当前企业的供应商库", notes = "查询当前企业的供应商库")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "orgName", value = "企业名称", dataTypeClass = String.class),
    })
    @PostMapping("/org/tender/history")
    public ResponseDto tenderHistory(@RequestBody OrgDTO orgDTO) {
        Long orgId = ShiroUtil.getOrgId();
        if (orgId == null) {
            return ResultUtil.fail("未能获取当前企业信息");
        }
        orgDTO.setId(orgId);

        Message<PageResult<OrgDTO>> pageResultMessage = orgClient.tenderHistory(orgDTO);
        return ResultUtil.msg(pageResultMessage);
    }

    /**
     * @param orgDTO:
     * @Description: 保存企业
     * @Author: zhongdl
     * @Date:2022/2/11 10:58
     * @return: {@link ResponseDto }
     **/
    @ApiOperation(value = "保存企业", notes = "保存企业")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "parentId", value = "父级id", dataTypeClass = Long.class),
            @ApiImplicitParam(name = "orgExt.capital", value = "注册资本", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgExt.regTime", value = "注册日期", dataTypeClass = Date.class),
            @ApiImplicitParam(name = "orgExt.addressInfo", value = "注册地址", dataTypeClass = String.class),
            @ApiImplicitParam(name = "orgExt.orgEmail", value = "企业邮箱", dataTypeClass = String.class),
            @ApiImplicitParam(name = "legalName", value = "法人姓名", dataTypeClass = String.class),
            @ApiImplicitParam(name = "certificateType", value = "证件类型", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "certificateNumber", value = "证件号码", dataTypeClass = String.class),
    })
    @PostMapping("/org/saveOrg")
    public ResponseDto<?> saveOrg(@RequestBody OrgDTO orgDTO) {
        // 参数验证
        String paramsValid = orgDTO.paramsValid();
        if (StrUtil.isNotEmpty(paramsValid)) {
            return ResultUtil.fail(paramsValid);
        }
        // 判断当前用户的企业是否为总公司
        Long parentId = orgDTO.getParentId();
        // 总公司的parentId为0或者null, 新增的只能是分公司
        if (parentId == null || parentId == 0L) {
            return ResultUtil.fail("分公司信息异常");
        }

        Long currentOrgId = ShiroUtil.getOrgId();
        Message<OrgDTO> orgMsg = orgClient.getOrgById(currentOrgId);
        if (orgMsg.isFail()) {
            return ResultUtil.msg(orgMsg);
        }
        if (orgMsg.getData().getParentId() == null || NumberUtil.equals(orgMsg.getData().getParentId(), 0L)) {
            orgDTO.setRoleSign(ShiroUtil.getExtInfo().getInt("roleSign"));
            Message<OrgDTO> saveOrg = orgClient.saveOrg(orgDTO);
            if (saveOrg.isSuccess()) {
                OrgDTO saveOrgData = saveOrg.getData();
                expertUserService.createExpertUser(saveOrgData.getId(), saveOrgData.getOrgName());
            }
            return ResultUtil.msg(saveOrg);
        }
        return ResultUtil.fail(MsgEnum.NO_AUTHORIZATION);
    }

    /**
     * @param orgDTO:
     * @Description: 删除企业
     * @Author: zhaojk
     * @Date:2022/2/11 10:58
     * @return: {@link ResponseDto }
     **/
    @ApiOperation(value = "删除企业", notes = "删除企业")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "主键ID", dataTypeClass = Long.class)
    })
    @PostMapping("/org/remove")
    public ResponseDto<?> remove(@RequestBody OrgDTO orgDTO) {
        Long id = orgDTO.getId();
        if (id == null) {
            return ResultUtil.msg(MsgEnum.INCORRECT_PARAM);
        }
        // 判断当前用户的企业是否为总公司
        Long currentOrgId = ShiroUtil.getOrgId();
        Message<OrgDTO> orgMsg = orgClient.getOrgById(currentOrgId);
        if (orgMsg.isFail()) {
            return ResultUtil.msg(orgMsg);
        }
        if (orgMsg.getData().getParentId() == null || NumberUtil.equals(orgMsg.getData().getParentId(), 0L)) {
            Message<Boolean> saveOrg = orgClient.removeOrgById(orgDTO);
            return ResultUtil.msg(saveOrg);
        }
        return ResultUtil.fail(MsgEnum.NO_AUTHORIZATION);
    }

    /**
     * 判断企业是否认证
     *
     * @return
     */
    @GetMapping("/org/orgConfirmFlag")
    public ResponseDto<?> orgConfirmFlag() {
        Long id = ShiroUtil.getOrgId();
        Message<OrgDTO> orgDTOMessage = orgClient.getOrgById(id);
        OrgDTO orgDTO = orgDTOMessage.getData();
        if (orgDTO == null) {
            return ResultUtil.FAIL;
        }
        if (!orgDTO.getParentId().equals(0L)) {
            Message<OrgDTO> orgMessage = orgClient.getHeadOffice(id);
            orgDTO = orgMessage.getData();
        }
        Integer roleSign = ShiroUtil.getExtInfoInt("roleSign");
        orgDTO.setRoleSign(roleSign);
        Message result = orgClient.orgConfirm(orgDTO);
        boolean orgConfirmFlag;
        if (result.isSuccess()) {
            orgConfirmFlag = true;
        } else {
            orgConfirmFlag = false;
        }
        JSONObject jsonObject = new JSONObject();
        jsonObject.putOnce("orgConfirmFlag", orgConfirmFlag);
        return ResultUtil.msg(true, jsonObject);
    }

    @ApiOperation(value = "验证中招企业信息", notes = "验证中招企业信息")
    @PostMapping("/org/checkOrgMsgByZapp")
    public ResponseDto<?> checkOrgMsgByZapp(@RequestBody ZappUserDTO zappUserDTO) {
        OrgDTO org = zappUserDTO.getOrg();
        org.setOrgId(ShiroUtil.getOrgId());
        return ResultUtil.msg(orgClient.checkOrgMsgByZapp(org));
    }
}
